package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.SystemUserEntity;
import com.jinmdz.fmis.mapper.mapper.provider.SystemUserProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 系统用户表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface SystemUserMapper {

    /**
     * 增加SystemUser
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = SystemUserProvider.class, method = "insertSystemUser")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertSystemUser(@Param("entity") SystemUserEntity entity);

    /**
     * 删除SystemUser
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update system_user set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForSystemUser(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改SystemUser
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = SystemUserProvider.class, method = "updateSystemUser")
    void updateSystemUser(@Param("entity") SystemUserEntity entity);

    /**
     * 查询SystemUser实体
     *
     * @param id 主键
     * @return SystemUserEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,login_username,login_password,login_secret_key,job_no,full_name,user_gender_code,mobile_phone,other_phone,address,company_id,department_id,disable_state,as_login,ic_card_code,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from system_user where id = #{id} and deleted = 0 limit 1 ")
    SystemUserEntity getSystemUserById(@Param("id") Integer id);

    /**
     * 查询SystemUser列表
     *
     * @param entity 数据实体
     * @return SystemUserEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = SystemUserProvider.class, method = "listSystemUser")
    ArrayList<SystemUserEntity> listSystemUser(@Param("entity") SystemUserEntity entity);
}